<?php

declare(strict_types=1);

namespace app\validate\cart;

use think\Validate;

class CartValidate extends Validate
{
    protected $rule = [
        'product_id' => 'integer|gt:0',
        'prod_id' => 'integer|gt:0',
        'qty' => 'integer|gt:0',
        'sku_id' => 'integer|gt:0',
        'remark' => 'max:255',
    ];

    protected $message = [
        'product_id.integer' => 'product_id 参数不合法',
        'product_id.gt' => 'product_id 参数不合法',
        'prod_id.integer' => 'prod_id 参数不合法',
        'prod_id.gt' => 'prod_id 参数不合法',
        'qty.integer' => '数量必须为整数',
        'qty.gt' => '数量必须大于0',
        'remark.max' => '备注长度不能超过255个字符',
    ];

    protected $scene = [
        'create' => ['qty', 'sku_id', 'remark'],
        'update' => ['qty', 'remark'],
    ];
}
